import gcjEncrypt from '@/utils/handle-location';
import { Map, Marker } from 'react-amap';
import { amapKey } from '@/utils/amap';

interface PatrolMapProps {
  location: number[];
}

export default (props: PatrolMapProps) => {
  const { location } = props;
  const coordinate = gcjEncrypt(location[1], location[0]);
  const position = { longitude: coordinate.lon, latitude: coordinate.lat };
  return (
    <div style={{ width: '100%', height: '100%' }}>
      <Map
        plugins={['Scale', 'ToolBar']}
        amapkey={amapKey}
        zoom={18}
        center={{
          lng: coordinate.lon,
          lat: coordinate.lat,
        }}
      >
        <Marker position={position} />
      </Map>
    </div>
  );
};
